package pl.vanta.mjuzik.gui;

import java.awt.Rectangle;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import com.google.inject.Inject;

import pl.vanta.mjuzik.model.Options;
import pl.vanta.mjuzik.services.ConfigurationService;

public class WindowHandler extends WindowAdapter
{
	ConfigurationService	configurationService;

	@Inject
	public WindowHandler(ConfigurationService configurationService)
	{
		super();
		this.configurationService = configurationService;
	}

	@Override
	public void windowClosing(WindowEvent e)
	{
		Rectangle r = e.getWindow().getBounds();

		Options o = this.configurationService.getOptions();
		o.setWindowBounds(r);
		this.configurationService.setOptions(o);
	}
}